//
//  CoustomSelctViewController.m
//  RONGAO
//
//  Created by wei wang on 2017/3/17.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "CoustomSelctViewController.h"
#import "EventListViewController.h"
@interface CoustomSelctViewController ()

@property (weak, nonatomic) IBOutlet UIDatePicker *starTimePicker;
@property (weak, nonatomic) IBOutlet UIDatePicker *endTimePicker;

@end

@implementation CoustomSelctViewController
@synthesize delegate;
@synthesize dateFormatter, dateFrom, dateTo;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setNavigationStyle];
    NSTimeInterval secondsPerDay = 24 * 60 * 60;
    dateFrom = [[NSDate alloc] initWithTimeIntervalSinceNow:-secondsPerDay];
    dateTo = [[NSDate alloc] init];
    
    self.dateFormatter = [[NSDateFormatter alloc] init];
    [self.dateFormatter setDateFormat:@"YYYY/MM/dd hh:mma"];

}
- (void)setNavigationStyle{
    
    [self setNavigationTitle:@"搜索范围" titleColor:[UIColor colorWithRed:210/255.0 green:177/255.0 blue:104/255.0 alpha:1]];
    [self setLeftButtonImage:[UIImage imageNamed:@"icon_back_nor"]];
    [self setRightButtonTitle:@"完成"];

}

- (void)onRightButtonClick:(id)sender{
    
    self.dateFrom = self.starTimePicker.date;
    self.dateTo = self.endTimePicker.date;
    
    
    
    [self.delegate customPeriodChanged:self.dateFrom dateTo:self.dateTo];
    
    for (UIViewController *controller in self.navigationController.viewControllers) {
        if ([controller isKindOfClass:[EventListViewController class]]) {
            
            EventListViewController *VC =(EventListViewController *)controller;
            [self.navigationController popToViewController:VC animated:YES];
        }
    }

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
